<?php 
declare (strict_types = 1);
namespace app\api\controller;
use app\common\controller\Api;
use think\Request;
class Lb extends Api
{
    //商户端-轮播图-列表
    public function bus_index()
    {
        $this->businessCheckLogin();
        $data = $this->model->where('business_id','=',$this->businessinfo['id'])->order('id desc')->select();
        return datasuccess($data);
    }
    //商户端-轮播图-添加
    public function add()
    {
        $this->businessCheckLogin();
        $post = param();
        $post['business_id'] = $this->businessinfo['id'];
        $this->model->save($post);
        return datasuccess([],'添加成功');
    }
    //商户端-轮播图-修改
    public function upload()
    {
        $this->businessCheckLogin();
        $post = param();
        if(!isset($post['id'])) return msgerror('参数缺失');
        $this->model::update($post);
        return datasuccess([],'修改成功');
    }
    //用户端-轮播图-列表
    public function index()
    {
        $post = param();
        if(!isset($post['id'])) return msgerror('参数缺失');
        $limit = input('limit') ?: 20;
        $data = $this->model->where([['business_id','=',$post['id']]])->order('id desc')->paginate($limit);
        return datasuccess($data);
    }
}